home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
051-075
/
scopedisk69
/
cclat
/
src
/
op.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-19
|
1KB
|
61 lines
/*
* file operands
* March 1989, Miles Bader (orig from cc.c by fred fish)
*/
#include "common.h"
#include "op.h"
/*
* Split an operand name into rootname, basename, and suffix
* components. The rootname is the full name, minus any suffix,
* but including any prefix. The basename is the rootname minus
* any prefix. The suffix is anything after the last '.' character.
* Only the suffix is allowed to be the null string.
*/
struct op *op_Create(filename)
char *filename;
{
char *split;
extern char *strrchr();
struct op *op=NEW(struct op);
DBUG_ENTER("op_Create");
DBUG_3("ops", "create op '%s'",filename);
if(op==NULL)
fatal("couldn't allocate an op");
op->rootname=filename;
split=strrchr(filename,'/');
if(split==NULL)
split=strrchr(filename,':');
if(split==NULL)
op->basename=filename;
else
op->basename=++split;
split=strrchr(filename,'.');
if(split==NULL)
op->suffix="";
else{
*split++='\0';
op->suffix=split;
}
DBUG_3("ops","rootname '%s'",op->rootname);
DBUG_3("ops","basename '%s'",op->basename);
DBUG_3("ops","suffix '%s'",op->suffix);
DBUG_RETURN(struct op *,op);
}
void op_Free(op)
struct op *op;
{
FREE(op);
}